package com.dyz.leetcode._20_dynamicProgramming;

public class _509_fib {
    public int fib(int n) {
        if(n==0){return 0;}
        if(n==1){return 1;}
        int left = fib(n-1);
        int right = fib(n-2);

        return left+right;
    }
    //
    public int fib1(int n) {
        if(n<=1){return n;}

        int[] arr = new int[n+1];
        arr[0] = 0;
        arr[1] = 1;
        for (int i = 2; i <=n ; i++) {
            arr[i] = arr[i-1]+arr[i-2];
        }
        return arr[n];
    }

}
